
public class TestTicket {
    volatile int sum = 5;

    public static void main(String args[]) {
        TestTicket testTicket = new TestTicket();
        testTicket.call();
    }

    public void call() {
        TicketThread a = new TicketThread("a");
        TicketThread b = new TicketThread("b");
        a.start();
        

    }

    class TicketThread extends Thread {
        private String Name;

        public TicketThread(String name) {
            Name = name;
        }

        @Override
        public void run() {
            for (int i = 0; sum>0; i++) {
                sum--;
                System.out.println(Name);
            }
        }
    }

}
